﻿#include "BlockingObject.h"
#include "../../../Shared/ServerPackets.h"

using namespace Server::MirDatabase;
using namespace Server::MirEnvir;
namespace S = ServerPackets;

namespace Server::MirObjects::Monsters
{

    BlockingObject::BlockingObject(MonsterObject *parent, MonsterInfo *info) : MonsterObject(info)
    {
        Parent = parent;
        Visible = true;
    }

    bool BlockingObject::getBlocking() const
    {
        return Parent->getBlocking();
    }

    bool BlockingObject::Walk(MirDirection dir)
    {
        return false;
    }

    bool BlockingObject::IsAttackTarget(MonsterObject *attacker)
    {
        return Parent->IsAttackTarget(attacker);
    }

    bool BlockingObject::IsAttackTarget(PlayerObject *attacker)
    {
        return Parent->IsAttackTarget(attacker);
    }

    void BlockingObject::ProcessRoam()
    {
    }

    void BlockingObject::ProcessSearch()
    {
    }

    int BlockingObject::Attacked(PlayerObject *attacker, int damage, DefenceType type, bool damageWeapon)
    {
        return Parent->Attacked(attacker, damage, type, damageWeapon);
    }

    void BlockingObject::Spawned()
    {
        MonsterObject::Spawned();
    }

    Packet *BlockingObject::GetInfo()
    {
        if (!Visible)
        {
            return nullptr;
        }

        return MonsterObject::GetInfo();
    }

    void BlockingObject::Hide()
    {
        Visible = false;

        if (getCurrentMap() == nullptr)
        {
            return;
        }

        S::ObjectRemove *tempVar = new S::ObjectRemove(), *CurrentLocation;
        tempVar->ObjectID = ObjectID;
        getCurrentMap()->Broadcast(tempVar, CurrentLocation);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void BlockingObject::Show()
    {
        Visible = true;

        if (getCurrentMap() == nullptr)
        {
            return;
        }

        Broadcast(GetInfo());
    }
}
